<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>phpWallet</title>

<link rel="stylesheet" type="text/css" href="js/yui/build/fonts/fonts-min.css" />
<link rel="stylesheet" type="text/css" href="js/yui/build/container/assets/skins/sam/container.css" />

<link rel="stylesheet" type="text/css" href="js/yui/build/button/assets/skins/sam/button.css" />

<link rel="stylesheet" type="text/css" href="js/yui/build/menu/assets/skins/sam/menu.css" />

<link rel="stylesheet" type="text/css" href="js/yui/build/tabview/assets/skins/sam/tabview.css" />

<link rel="stylesheet" type="text/css" href="js/yui/build/datatable/assets/skins/sam/datatable.css" />

<script type="text/javascript" src="js/yui/build/yahoo/yahoo.js"></script>
<script type="text/javascript" src="js/yui/build/event/event.js"></script>
<script type="text/javascript" src="js/yui/build/connection/connection.js"></script>

<script type="text/javascript" src="js/yui/build/json/json-beta.js"></script>

<script type="text/javascript" src="js/yui/build/yahoo-dom-event/yahoo-dom-event.js"></script>

<script type="text/javascript" src="js/yui/build/dragdrop/dragdrop.js"></script>
<script type="text/javascript" src="js/yui/build/container/container.js"></script>

<script type="text/javascript" src="js/yui/build/utilities/utilities.js"></script>

<script type="text/javascript" src="js/yui/build/menu/menu.js"></script>

<script type="text/javascript" src="js/yui/build/button/button.js"></script>

<script type="text/javascript" src="js/yui/build/tabview/tabview.js"></script>

<script type="text/javascript" src="js/yui/build/datasource/datasource-beta.js"></script>
<script type="text/javascript" src="js/yui/build/datatable/datatable-beta.js"></script>

<link rel="stylesheet" type="text/css" href="js/yuifx/assets/yuifx.css" />
<script type="text/javascript" src="js/yuifx/yuifx.js"></script>

<link rel="stylesheet" type="text/css" href="css/money/money.css" />
<script type="text/javascript" src="js/money/util.js"></script>
<script type="text/javascript" src="js/money/account.js"></script>
<script type="text/javascript" src="js/money/money.js"></script>
</head>
<body>
<?php

include_once("controller/action/AccountAction.php");
$action = new AccountAction();
$accountList = $action->index();
$inAccountList = $accountList["in"];
$outAccountList = $accountList["out"];

$accountStats = $action->stats();

$accountCategory = $action->selectCategory();
?>

<div id="board">
	<div class="hd">Money Board - Your honest money manager</div>
	<div class="bd">
		<div id="toolbar">
			<fieldset id="add-info">
				<legend>Add</legend>
				<button id="add-in">Income</button>
				<button id="add-out">Expenditure</button>		
			</fieldset>
			
			<!--
			<fieldset id="view-info">
				<legend>View</legend>
				<button id="view-in">Income</button>
				<button id="view-out">Expenditure</button>		
			</fieldset>
			-->
		</div>
		
		<div id="content">
			<div id="account-info" class="yui-navset">
			    <ul class="yui-nav">
			    	<li><a href="#tab-view-overview"><em>Over View</em></a></li>
			        <li><a href="#tab-view-in"><em>Income</em></a></li>
			        <li><a href="#tab-view-out"><em>Expenditure</em></a></li>
			    </ul>            
			    <div class="yui-content">
			    	<div id="tab-view-overview">
			    		<select>
			    			<option>按月查看</option>
			    			<option>按年查看</option>
			    		</select>
			        	
			        	<div id="stats-data-table"></div>
			        </div>
			        <div id="tab-view-in">
			        	<div id="in-data-table"></div>
			        </div>
			        <div id="tab-view-out">
			        	<div id="out-data-table"></div>
			        </div>
			    </div>
			</div>
		</div>		
	</div>
	<div class="ft">Copyright &copy; 2007 Biao Zhang</div>
</div>

<div id="template" class="template">
	<div id="account-detail-panel-template" style="display: none;">
		<div class="hd">
			<span class="title">Account - Detail</span>
		</div>
		<div class="bd" id="account-detail-panel-body">
		
		</div>
		<div class="ft">Account Detail Information</div>
	</div>
	
	<div id="account-in-category-panel-template" style="display: none">
		<div class="hd">Add a category</div>
		<div class="bd">
			<input id="in-add-category-input" type="text" />
			<button id="in-add-category-ok-button">OK</button>
		</div>
		<div class="ft">Enter the category name, then press "OK"</div>
	</div>
	
	<div id="account-out-category-panel-template" style="display: none">
		<div class="hd">Add a category</div>
		<div class="bd">
			<input id="out-add-category-input" type="text" />
			<button id="out-add-category-ok-button">OK</button>
		</div>
		<div class="ft">Enter the category name, then press "OK"</div>
	</div>
	
	<div id="account-in-dialog-template">
		<div class="hd">Account - Add Income</div>
		<div class="bd">
			<form method="POST" action="account.php?add&type=in">
				<div class="x-form-item">
					<label for="amount">Amount:</label>
					
					<div>
						<input type="text" name="amount" />
					</div>
					
					<div class="clear"></div>
				</div>
				
				<div class="x-form-item">
					<label for="description">Description:</label>
					<input type="text" name="description" />
					
					<div class="clear"></div>
				</div>
				
				<div class="x-form-item">
					<label for="date">Date:</label>
					<input type="text" name="date" />
		
					<div class="clear"></div>
				</div>
								
				<div class="x-form-item">
					<label for="category">Category:</label>
					<select id="account-in-select" name="category">
						<?php foreach($accountCategory["in"] as $row) { ?>
						<option value="<?php echo $row["category"]; ?>"><?php echo $row["category"]; ?></option>
						<?php } ?>
					</select>
					
					<button id="add-in-catalog-button">Add</button>
					
					<div class="clear"></div>
				</div>
								
				<div class="x-form-item">
					<label for="tag">Tags:</label>
					<input type="text" name="tag" />
					
					<div class="clear"></div>
				</div>
				
				<div class="x-form-item">
					<label for="detail">Detail Information:</label>
					<textarea name="detail" rows="10"></textarea>
				</div>
			</form>
			
		</div>
		<div class="ft"></div>
	</div>
	
	<div id="account-out-dialog-template">
		<div class="hd">Account - Add Expenditure</div>
		<div class="bd">
			<form method="POST" action="account.php?add&type=out">
				<div class="x-form-item">
					<label for="amount">Amount:</label>
					
					<div>
						<input type="text" name="amount" />
					</div>
					
					<div class="clear"></div>
				</div>
				
				<div class="x-form-item">
					<label for="description">Description:</label>
					<input type="text" name="description" />
					
					<div class="clear"></div>
				</div>
				
				<div class="x-form-item">
					<label for="date">Date:</label>
					<input type="text" name="date" />
		
					<div class="clear"></div>
				</div>
								
				<div class="x-form-item">
					<label for="category">Category:</label>
					<select id="account-out-select" name="category">
						<?php foreach($accountCategory["out"] as $row) { ?>
						<option value="<?php echo $row["category"]; ?>"><?php echo $row["category"]; ?></option>
						<?php } ?>
					</select>
					
					<button id="add-out-catalog-button">Add</button>
					
					<div class="clear"></div>
				</div>
								
				<div class="x-form-item">
					<label for="tag">Tags:</label>
					<input type="text" name="tag" />
					
					<div class="clear"></div>
				</div>
				
				<div class="x-form-item">
					<label for="detail">Detail Information:</label>
					<textarea name="detail" rows="10"></textarea>
				</div>
			</form>
		</div>
		<div class="ft"></div>
	</div>
	
	<table id="in-table" style="display: none;">
		<thead>
			<tr>
				<th>ID</th>
				<th>Category</th>
				<th>Date</th>
				<th>Amount</th>
				<th>Description</th>
				<th>Add-Oper</th>
				<th>Del-Oper</th>
			</tr>
		</thead>
		<tbody>
		<?php foreach($inAccountList as $account) {?>
			<tr>
				<td><?php echo $account->getId(); ?></td>
				<td><?php echo $account->getCategory(); ?></td>
				<td><?php echo $account->getDate(); ?></td>
				<td><?php echo $account->getAmount(); ?></td>
				<td><?php echo $account->getDescription(); ?></td>
				<td><?php echo $account->getId(); ?></td>
				<td><?php echo $account->getId(); ?></td>
			</tr>
		<?php } ?>
		</tbody>
	</table>
	
	<table id="out-table" style="display: none;">
		<thead>
			<tr>
				<th>ID</th>
				<th>Category</th>
				<th>Date</th>
				<th>Amount</th>
				<th>Description</th>
				<th>Add-Oper</th>
				<th>Del-Oper</th>
			</tr>
		</thead>
		<tbody>
			<?php foreach($outAccountList as $account) {?>
			<tr>
				<td><?php echo $account->getId(); ?></td>
				<td><?php echo $account->getCategory(); ?></td>
				<td><?php echo $account->getDate(); ?></td>
				<td><?php echo $account->getAmount(); ?></td>
				<td><?php echo $account->getDescription(); ?></td>
				<td><?php echo $account->getId(); ?></td>
				<td><?php echo $account->getId(); ?></td>
			</tr>
			<?php } ?>
		</tbody>
	</table>
	
	<table id="stats-table"  style="display: none;">
		<thead>
			<tr>
				<th>Category</th>
				<th>Count</th>
				<th>Amount</th>
			</tr>
		</thead>
		<tbody>
			<?php foreach($accountStats as $stats) {?>
			<tr>
				<td><?php echo $stats["category"]; ?></td>
				<td><?php echo $stats["count"]; ?></td>
				<td><?php echo $stats["amount"]; ?></td>
			</tr>
			<?php } ?>
		</tbody>
	</table>
</div>

</body>
</html>